<!--  -->
<template>
  <div class="childrenGroup">
    <div class="childrenGroupjia">
      <HomeTop :topTitle="topTitle"></HomeTop>
    </div>
    <div class="childrenGroup-head">
      <div class="childrenGroup-head-one">
        <img class="image_path" :src="image_path" alt="" />
      </div>
      <div class="childrenGrouplist">
        <div class="head">组别</div>
        <div class="zubielist">
          <div class="zubielists" @click="match('1')"></div>
          <div class="zubielists1" @click="match('2')"></div>
          <div class="zubielists2" @click="match('3')"></div>
          <div class="zubielists3" @click="match('4')"></div>
        </div>
      </div>
      <van-dialog
        v-model="show"
        title="选择比赛类型"
        width="5.2rem"
        :showConfirmButton="false"
        :closeOnClickOverlay="true"
      >
        <div class="zubielistsd">
          <div
            class="coach_home_examination_process_item"
            @click="toCoachRegisterFn('1')"
          >
            <img
              class="coach_home_examination_process_item_img"
              src="../../assets/image/jjs.png"
            />
          </div>
          <div
            class="coach_home_examination_process_item"
            @click="toCoachRegisterFn('2')"
          >
            <img
              class="coach_home_examination_process_item_img"
              src="../../assets/image/js.png"
            />
          </div>
        </div>
      </van-dialog>
      <div class="childrenGrouplist">
        <div class="head">功能</div>
        <div class="zubielistsd">
          <div
            class="coach_home_examination_process_item"
            @click="toGameRulesFn('1')"
          >
            <img
              class="coach_home_examination_process_item_img"
              src="../../assets/image/function_gameRules_img.png"
            />
          </div>
          <div
            class="coach_home_examination_process_item"
            @click="toGameRulesFn(2)"
          >
            <img
              class="coach_home_examination_process_item_img"
              src="../../assets/image/function_teamMessage_img.png"
            />
          </div>
          <div
            class="coach_home_examination_process_item"
            @click="toGameRulesFn(6)"
          >
            <img
              class="coach_home_examination_process_item_img"
              src="../../assets/image/function_sign_img.png"
            />
          </div>
          <div
            class="coach_home_examination_process_item"
            @click="toGameRulesFn(3)"
          >
            <img
              class="coach_home_examination_process_item_img"
              src="../../assets/image/info_search.png"
            />
          </div>
          <div
            class="coach_home_examination_process_item"
            @click="toGameRulesFn(4)"
          >
            <img
              class="coach_home_examination_process_item_img"
              src="../../assets/image/watch_live.png"
            />
          </div>
          <div
            class="coach_home_examination_process_item"
            @click="toGameRulesFn(5)"
          >
            <img
              class="coach_home_examination_process_item_img"
              src="../../assets/image/my_apply.png"
            />
          </div>
        </div>
      </div>
      <div class="coach_home_label_title">公告</div>
      <div id="coach_home_news_box">
        <div class="coach_home_news_list">
          <div
            class="coach_home_news_item"
            v-for="(item, index) in annlist"
            :key="index"
            @click="content(item)"
          >
            <div class="coach_home_news_item_top">
              <div class="coach_home_news_item_title">{{ item.title }}</div>
            </div>
            <div class="coach_home_news_item_bottom">
              <div class="coach_home_news_item_time">{{ item.date }}</div>
              <div class="coach_home_news_item_tips">查看详情 ></div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div style="height: 1.15rem"></div>
    <HomeFooter :activeKey="activeKey" :systemKey="systemKey"></HomeFooter>
  </div>
</template>
<style src="../../assets/css/game/childrenGroup.css" scoped></style>

<script>
//
import HomeTop from "@/components/homeTop.vue";
import HomeFooter from "@/components/homeFooter.vue";
import { Indicator, Toast } from "mint-ui";
import "vant/lib/dialog/style";
import { Dialog } from "vant";
export default {
  name: "childrenGroup",
  components: {
    HomeTop,
    HomeFooter,
    [Dialog.Component.name]: Dialog.Component,
  },
  data() {
    return {
      image_path: "",
      activeKey: 1,
      systemKey: 1,
      show: false,
      grade: "",
      type: "",
      topTitle: "", // 顶部组件参数设置
      annlist: [],
    };
  },
  mounted() {
    this.image_path = this.$route.query.image_path;
    this.announceList();
  },
  methods: {
    match(idenx) {
      // console.log("12");
      this.show = true;
      this.grade = idenx;
      // this.$router.push({
      //   name: "childrenGroupU",
      // });
    },
    //查看竞赛规程
    toGameRulesFn(index) {
      if (index == 1) {
        this.$router.push({
          name: "gameRules",
        });
      } else if (index == 4) {
        //前往观看直播
        Toast({
          message: "暂无开放",
          duration: 3000,
        });
        // this.$router.push({
        //   name: "watchLive",
        // })
      } else if (index == 6) {
        //裁判员签到
        this.$router.push({
          name: "signinlist",
        });
        // Toast({
        //   message: "裁判员签到",
        //   duration: 3000,
        // });
      } else {
        // console.log(1111111);
        let url = "/mobile/checkUserInfo";
        Indicator.open();
        this.axios
          .post(url)
          .then((res) => {
            Indicator.close();
            if (res.code == 0) {
              //进入球队信息
              if (index == 2) {
                if (res.is_complete == "2") {
                  this.$router.push({
                    name: "teamlist",
                  });
                } else if (res.is_complete == "1") {
                  Toast({
                    message: "请去教练员系统完善信息",
                    duration: 3000,
                  });
                }
                //进入信息搜索
              } else if (index == 3) {
                // Toast({
                //   message: "暂无开放",
                //   duration: 3000,
                // });
                if (res.is_complete == "2") {
                  this.$router.push({
                    name: "informationSearch",
                  });
                } else if (res.is_complete == "1") {
                  Toast({
                    message: "请去教练员系统完善信息",
                    duration: 3000,
                  });
                }
                //前往我的报名
              } else if (index == 5) {
                if (res.is_complete == "2") {
                  this.$router.push({
                    name: "myApply",
                  });
                } else if (res.is_complete == "1") {
                  Toast({
                    message: "请去教练员系统完善信息",
                    duration: 3000,
                  });
                }
                // Toast({
                //   message: "暂无开放",
                //   duration: 3000,
                // });
              }
            } else {
              Toast({
                message: res.msg,
                duration: 3000,
              });
            }
          })
          .catch(function (error) {
            Indicator.close();
            console.log(error);
          });
      }
    },

    //选择比赛类型
    toCoachRegisterFn(index) {
      this.type = index;
      // console.log(index);
      this.$router.push({
        name: "uList",
        query: {
          id: this.$route.query.id,
          grade: this.grade,
          type: this.type,
        },
      });
    },
    //页面进入渲染
    announceList() {
      let url = "/mobile/announceList";
      Indicator.open();
      this.axios
        .post(url)
        .then((res) => {
          Indicator.close();
          if (res.code == 0) {
            this.annlist = res.announce;
            // console.log(this.annlist, "22222");
          } else {
            Toast({
              message: res.msg,
              duration: 3000,
            });
          }
        })
        .catch(function (error) {
          Indicator.close();
          console.log(error);
        });
    },
    content(item) {
      if (item.type == "1") {
        window.location.href = item.content;
      } else if (item.type == "2") {
        Toast({
          message: item.content,
          duration: 3000,
        });
      }
    },
  },
};
</script>

<style scoped lang="scss"></style>
